OB.Wms_ActionButton = OB.Wms_ActionButton || {};

//退货到供应商
OB.Wms_ActionButton.ReturnGoodsToVendor = function(params, view) {
	var viewGrid = view.view.viewGrid;
	var record = viewGrid.getSelectedRecord();
	if (record) {
		if(record._entityName !="Wms_Return_Goods"){
			isc.showMessage("请选择一条有效记录。");
			return false;
		}
		if(record.status !="1"){
			isc.showMessage("该记录已经处理，请仔细检查。");
			return false;
		}
		
	} else {
		isc.showMessage("请选择一条记录进行分解！");
	}
};

//采购退货审核按钮事件
OB.Wms_ActionButton.CheckReturnGoodsOrder =  function(params, view) {
	var viewGrid = view.activeView.viewGrid;
	var record = viewGrid.getSelectedRecord();
	var row = viewGrid.getRecordIndex(record);
	if (record) {
		var callback = function(response, data, request){
			selfDef_Window.closeClick();
			isc.showMessage(data.msg);
			view.refresh();
		};
		//弹出自定义窗口
		this.msgInfo = isc.Label.create({
			align: "center",
			padding: 5,
			width: "100%",
			//height: "135",
			contents: "<span style='font-size:15px;'>是否审核通过？</span><p align='left' style='padding-left:50px;'>审核意见：</p><p><textarea id='checkLog' rows='3' cols='20'></textarea></p>"
		});
		
		selfDef_Window = isc.Window.create({
			id: "selfDef_Window",
			width: 320,
			//height: 100,
			title: '采购退货单审核',
			canDragResize: false,
			canDragReposition: true,
			showCloseButton: true,
			showMinimizeButton: false,
			autoCenter:true,
			autoSize:true,
			isModal:true,
			closeClick:function(){
				selfDef_Window.destroy();
			},
			items: [
				isc.VLayout.create({
					width: "100%",
					height: "70",
					align: "center",
					members: [
						this.msgInfo,
						isc.HLayout.create({
							width: "100%",
							height: "30",
							align: "center",
							padding: 5,
							members: [
								isc.OBFormButton.create({
									title : '通过',
									popup : this,
									action : function() {
										var checkLog = document.getElementById("checkLog");
										var checkLogVal = checkLog.value;
										var data = {
												recordId: record[OB.Constants.ID],
												isPass:true,
												type: "default",
												description:checkLogVal
										};
										OB.RemoteCallManager.call("com.wms.handler.returns.WmsReturnGoodsPutCheckHandler", data, {}, callback);
									}
								}),
								isc.OBFormButton.create({
									title : '不通过',
									popup : this,
									action : function() {
										var checkLog = document.getElementById("checkLog");
										var checkLogVal = checkLog.value;
										var data = {
												recordId: record[OB.Constants.ID],
												isPass:false,
												type: "default",
												description:checkLogVal
										};
										OB.RemoteCallManager.call("com.wms.handler.returns.WmsReturnGoodsPutCheckHandler", data, {}, callback);
									}
								})
							]
						})
					]
				})
			]
		});
		//弹出确认框
		selfDef_Window.show();
	} else {
		isc.showMessage("请选择纪录！");
	}
};